<template>

</template>

<script setup>
  import {useRoute} from "vue-router";
  import axiosInstance from "@/axios/index.js";
  import {useStudentStore} from "@/stores/student.js";
  import router from "@/router/index.js";

  const code = useRoute().query.code;
  const state = useRoute().query.state;

  //发起微信登录
  axiosInstance.get('/student/wxlogin', {params: {
      code: code,
      state: state,
    }}).then(resp => {
    localStorage.setItem("frontToken", resp.data.data.token);
    useStudentStore().getStudentInfo(resp.data.data.studentId)
    router.push("/index")
  }).catch(error => {
    console.log(error)
    console.log(error.data)
    router.push({path:'/wxBind',query:
    {
      openId: error.data
    }})
  })
</script>

<style scoped>

</style>